---
id: command-line-interface
sidebar_label: Command Line Interface
title: Command Line Interface
description: Command line interface for open source chatbot framework Rasa. Learn how to train, test and run your machine learning-based conversational AI assistants
abstract: The command line interface (CLI) gives you easy-to-remember commands for common tasks. This page describes the behavior of the commands and the parameters you can pass to them.
---

## Cheat Sheet


|        Command         |                                                                  Effect                                                                  |
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
|`rasa init`             |Creates a new project with example training data, actions, and config files.                                                              |
|`rasa train`            |Trains a model using your NLU data and stories, saves trained model in `./models`.                                                        |
|`rasa interactive`      |Starts an interactive learning session to create new training data by chatting to your assistant.                                         |
|`rasa shell`            |Loads your trained model and lets you talk to your assistant on the command line.                                                         |
|`rasa run`              |Starts a server with your trained model.                                                                                                  |
|`rasa run actions`      |Starts an action server using the Rasa SDK.                                                                                               |
|`rasa visualize`        |Generates a visual representation of your stories.                                                                                                                                                            |
|`rasa test`             |Tests a trained Rasa model on any files starting with `test_`.                                                                            |
|`rasa data split nlu`   |Performs a 80/20 split of your NLU training data.                                                                                         |
|`rasa data convert`     |Converts training data between different formats.                                                                                         |
|`rasa data validate`    |Checks the domain, NLU and conversation data for inconsistencies.                                                                                             |
|`rasa export`           |Exports conversations from a tracker store to an event broker.                                                                            |
|`rasa x`                |Launches Rasa X in local mode.                                                                                                            |
|`rasa -h`               |Shows all available commands.                                                                                                             |

## rasa init

This command sets up a complete assistant for you with some example training data:

```bash
rasa init
```

It creates the following files:

```bash
.
├── actions
│   ├── __init__.py
│   └── actions.py
├── config.yml
├── credentials.yml
├── data
│   ├── nlu.yml
│   └── stories.yml
├── domain.yml
├── endpoints.yml
├── models
│   └── <timestamp>.tar.gz
└── tests
   └── test_stories.yml
```

It will ask you if you want to train an initial model using this data.
If you answer no, the `models` directory will be empty.

Any of the default CLI commands will expect this project setup, so this is the
best way to get started. You can run `rasa train`, `rasa shell` and `rasa test`
without any additional configuration.

## rasa train

The following command trains a Rasa Open Source model:

```bash
rasa train
```
If you have existing models in your directory (under `models/` by default), only
the parts of your model that have changed will be re-trained. For example, if you edit
your NLU training data and nothing else, only the NLU part will be trained.

If you want to train an NLU or dialogue model individually, you can run
`rasa train nlu` or `rasa train core`. If you provide training data only for one one of
these, `rasa train` will fall back to one of these commands by default.

`rasa train` will store the trained model in the directory defined by `--out`, `models/` by default.
The name of the model by default is `<timestamp>.tar.gz`. If you want to name your model differently,
you can specify the name using the `--fixed-model-name` flag.

The following arguments can be used to configure the training process:

```text [rasa train --help]
```

### Incremental training

:::caution
This feature is experimental.
We introduce experimental features to get feedback from our community, so we encourage you to try it out!
However, the functionality might be changed or removed in the future.
If you have feedback (positive or negative) please share it with us on the [Rasa Forum](https://forum.rasa.com).

:::

In order to improve the performance of an assistant, it's helpful to practice [CDD](./conversation-driven-development.mdx)
and add new training examples based on how your users have talked to your assistant. You can use `rasa train --finetune`
to initialize the pipeline with an already trained model and further finetune it on the
new training dataset that includes the additional training examples. This will help reduce the
training time of the new model.

By default, the command picks up the latest model in the `models/` directory. If you have a specific model
which you want to improve, you may specify the path to this by
running `rasa train --finetune <path to model to finetune>`. Finetuning a model usually
requires fewer epochs to train machine learning components like `DIETClassifier`, `ResponseSelector` and `TEDPolicy` compared to training from scratch.
Either use a model configuration for finetuning
which defines fewer epochs than before or use the flag
`--epoch-fraction`. `--epoch-fraction` will use a fraction of the epochs specified for each machine learning component
in the model configuration file. For example, if `DIETClassifier` is configured to use 100 epochs,
specifying `--epoch-fraction 0.5` will only use 50 epochs for finetuning.

You can also finetune an NLU-only or dialogue management-only model by using
`rasa train nlu --finetune` and `rasa train core --finetune` respectively.

To be able to fine tune a model, the following conditions must be met:

1. The configuration supplied should be exactly the same as the
configuration used to train the model which is being finetuned.
The only parameter that you can change is `epochs` for the individual machine learning components and policies.

2. The set of labels(intents, actions, entities and slots) for which the base model is trained
should be exactly the same as the ones present in the training data used for finetuning. This
means that you cannot add new intent, action, entity or slot labels to your training data
during incremental training. You can still add new training examples for each of the existing
labels. If you have added/removed labels in the training data, the pipeline needs to be trained
from scratch.

3. The model to be finetuned is trained with `MINIMUM_COMPATIBLE_VERSION` of the currently installed rasa version.

## rasa interactive

You can [use Rasa X in local mode](https://rasa.com/docs/rasa-x) to do interactive learning in a UI,
check out the [docs](https://rasa.com/docs/rasa-x/user-guide/test-assistant#talk-to-your-bot)
for more details.

If you'd rather use the command line, you can start an interactive learning session by running:

```bash
rasa interactive
```

This will first train a model and then start an interactive shell session.
You can then correct your assistants predictions as you talk to it.
If [`UnexpecTEDIntentPolicy`](./policies.mdx#unexpected-intent-policy) is
included in the pipeline, [`action_unlikely_intent`](./default-actions.mdx#action_unlikely_intent)
can be triggered at any conversation turn. Subsequently, the following message will be displayed:

```
 The bot wants to run 'action_unlikely_intent' to indicate that the last user message was unexpected
 at this point in the conversation. Check out UnexpecTEDIntentPolicy docs to learn more.
```

 As the message states, this is an indication that you have explored a conversation path
 which is unexpected according to the current set of training stories and hence adding this
 path to training stories is recommended. Like other bot actions, you can choose to confirm
 or deny running this action.


If you provide a trained model using the `--model` argument, training is skipped
and that model will be loaded instead.

During interactive learning, Rasa will plot the current conversation
and a few similar conversations from the training data to help you
keep track of where you are. You can view the visualization
at http://localhost:5005/visualization.html
as soon as the session has started. This diagram can take some time to generate.
To skip the visualization, run `rasa interactive --skip-visualization`.


The following arguments can be used to configure the interactive learning session:

```text [rasa interactive --help]
```

## rasa shell

You can [use Rasa X in local mode](https://rasa.com/docs/rasa-x) to talk to your assistant in a UI.
Check out the [Rasa X docs](https://rasa.com/docs/rasa-x/user-guide/test-assistant#talk-to-your-bot)
for more details.

If you'd rather use the command line, you can start a chat session by running:

```bash
rasa shell
```

By default this will load up the latest trained model.
You can specify a different model to be loaded by using the `--model` flag.

If you start the shell with an NLU-only model, `rasa shell` will output the
intents and entities predicted for any message you enter.

If you have trained a combined Rasa model but only want to see what your model
extracts as intents and entities from text, you can use the command `rasa shell nlu`.

To increase the logging level for debugging, run:

```bash
rasa shell --debug
```

:::note
In order to see the typical greetings and/or session start behavior you might see
in an external channel, you will need to explicitly send `/session_start`
as the first message. Otherwise, the session start behavior will begin as described in
[Session configuration](./domain.mdx#session-configuration).
:::

The following arguments can be used to configure the command:

```text [rasa shell --help]
```

## rasa run

To start a server running your trained model, run:

```bash
rasa run
```

By default the Rasa server uses HTTP for its communication. To secure the communication with
SSL and run the server on HTTPS, you need to provide a valid certificate and the corresponding
private key file. You can specify these files as part of the `rasa run` command.
If you encrypted your keyfile with a password during creation,
you need to add the `--ssl-password` as well.

```bash
rasa run --ssl-certificate myssl.crt --ssl-keyfile myssl.key --ssl-password mypassword
```

Rasa by default listens on each available network interface. You can limit this to a specific 
network interface using the `-i` command line option.

```bash
rasa run -i 192.168.69.150
```

The following arguments can be used to configure your Rasa server:

```text [rasa run --help]
```

For more information on the additional parameters, see [Model Storage](./model-storage.mdx).
See the Rasa [HTTP API](./http-api.mdx) page for detailed documentation of all the endpoints.

## rasa run actions

To start an action server with the Rasa SDK, run:

```bash
rasa run actions
```

The following arguments can be used to adapt the server settings:

```text [rasa run actions --help]
```

## rasa visualize

To generate a graph of your stories in the browser, run:

```bash
rasa visualize
```

If your stories are located somewhere other than the default location `data/`,
you can specify their location with the `--stories` flag.

The following arguments can be used to configure this command:

```text [rasa visualize --help]
```

## rasa test

To evaluate a model on your test data, run:

```bash
rasa test
```

This will test your latest trained model on any end-to-end stories you have
defined in files with the `test_` prefix.
If you want to use a different model, you can specify it using the `--model` flag.

If you want to evaluate the dialogue and NLU
models separately, you can use the commands below:
```bash
rasa test core
```
and

```bash
rasa test nlu
```

You can find more details in
[Evaluating an NLU Model](./testing-your-assistant.mdx#evaluating-an-nlu-model) and
[Evaluating a Core Model](./testing-your-assistant.mdx#evaluating-a-dialogue-model).

The following arguments are available for `rasa test`:

```text [rasa test --help]
```

## rasa data split

To create a train-test split of your NLU training data, run:

```bash
rasa data split nlu
```

This will create a 80/20 split of train/test data by default.
You can specify the training data, the fraction, and the output directory using
the following arguments:

```text [rasa data split nlu --help]
```

If you have NLG data for retrieval actions, this will be saved to seperate files:

```bash
ls train_test_split

      nlg_test_data.yml     test_data.yml
      nlg_training_data.yml training_data.yml
```

## rasa data convert nlu

You can convert NLU data from
- LUIS data format,
- WIT data format,
- Dialogflow data format, or
- JSON

to
- YAML or
- JSON

You can start the converter by running:

```bash
rasa data convert nlu
```

You can specify the input file or directory, output file or directory, and the output format with the following arguments:

```text [rasa data convert nlu --help]
```

## rasa data validate

You can check your domain, NLU data, or story data for mistakes and inconsistencies. 
To validate your data, run this command:

```bash
rasa data validate
```

The validator searches for errors in the data, e.g. two intents that have some
identical training examples.
The validator also checks if you have any stories where different assistant actions follow from the same 
dialogue history. Conflicts between stories will prevent a model from learning the correct
pattern for a dialogue. 

If you pass a `max_history` value to one or more policies in your `config.yml` file, provide the 
smallest of those values in the validator command using the `--max-history <max_history>` flag. 

You can also validate only the story structure by running this command:

```bash
rasa data validate stories
```

:::note
Running `rasa data validate` does **not** test if your [rules](./rules.mdx) are consistent with your stories. 
However, during training, the `RulePolicy` checks for conflicts between rules and stories. Any such conflict will abort training.

Also, if you use end-to-end stories, then this might not capture all conflicts. Specifically, if two user inputs
result in different tokens yet exactly the same featurization, then conflicting actions after these inputs
may exist but will not be reported by the tool. 
:::

To interrupt validation even for minor issues such as unused intents or responses, use the `--fail-on-warnings` flag.

:::caution check your story names
The `rasa data validate stories` command assumes that all your story names are unique!
:::

You can use `rasa data validate` with additional arguments, e.g. to specify the location of your data and 
domain files:

```text [rasa data validate --help]
```

## rasa export

To export events from a tracker store using an event broker, run:

```bash
rasa export
```

You can specify the location of the environments file, the minimum and maximum
timestamps of events that should be published, as well as the conversation IDs that
should be published:

```text [rasa export --help]
```

:::tip Import conversations into Rasa X
This command is most commonly used to import old conversations into Rasa X to annotate
them. Read more about [importing conversations into Rasa X](https://rasa.com/docs/rasa-x/installation-and-setup/deploy#1-import-existing-conversations-from-rasa-open-source).
:::

## rasa x

Rasa X is a tool for practicing Conversation-Driven Development.
You can find more information about it <a className="reference external" href="https://rasa.com/docs/rasa-x/" target="_blank">here</a>.You can start Rasa X in local mode by executing

```bash
rasa x
```

To be able to start Rasa X you need to have Rasa X local mode [installed](https://rasa.com/docs/rasa-x/installation-and-setup/install/local-mode)
and you need to be in a Rasa project directory.


The following arguments are available for `rasa x`:

```text [rasa x --help]
```
